import axios from 'axios';

// 获取用户列表
export const getUserList = async () => {
  const token = localStorage.getItem('token');
  return axios.get('/api/admin/list', {
    headers: {
      'Authorization': `Bearer ${token}`
    }
  });
};

// 用户注册
export const registerUser = async (userData) => {
  const token = localStorage.getItem('token');
  return axios.post('/api/admin/register', userData, {
    headers: {
      'Authorization': `Bearer ${token}`
    }
  });
};

// 修改用户信息
export const updateUser = async (userData) => {
  const token = localStorage.getItem('token');
  return axios.put('/api/admin/update', userData, {
    headers: {
      'Authorization': `Bearer ${token}`
    }
  });
};

// 删除用户
export const deleteUser = async (userId) => {
  const token = localStorage.getItem('token');
  return axios.delete(`/api/admin/${userId}`, {
    headers: {
      'Authorization': `Bearer ${token}`
    }
  });
};

// 检查管理员账号是否存在
export const checkAdminAccount = async () => {
  const token = localStorage.getItem('token');
  return axios.get('/api/admin/check-admin', {
    headers: {
      'Authorization': `Bearer ${token}`
    }
  });
};

// 初始化管理员账号
export const initAdminAccount = async () => {
  const token = localStorage.getItem('token');
  return axios.post('/api/admin/init-admin', {
    name: 'admin',
    password: 'Admin@123',
    nickname: '超级管理员',
    remark: ''
  }, {
    headers: {
      'Authorization': `Bearer ${token}`
    }
  });
}; 